import math_functions

while True:
    print("欢迎使用功能程序，请选择要执行的功能（输入对应编号），输入'q'退出：")
    print("1. 判断某年某月某日是这一年的第几天")
    print("2. 输出9x9乘法口诀表")
    print("3. 判断1000中有多少个素数，并输出所有素数")
    print("4. 输入一个任意正整数，输出分解质因数")
    print("5. 利用条件运算符的嵌套来完成成绩等级判断")
    print("6. 输入一个不多于6位的正整数相关操作")
    print("7. 输入一行字符串，统计各类字符个数")
    print("8. 求特定式子的和")
    print("9. 找出1000以内的所有完数")
    print("10. 求分数序列前N项之和")
    print("11. 求1+2!+3!+...+N!的值")
    print("12. 找出满足条件的整数")
    print("13. 按要求打印菱形图案")
    print("14. 计算每个月的兔子总数")
    print("15. 对10个数进行排序")
    print("16. 求矩阵对角线元素之和")
    print("17. 将数插入已排好序的数组")
    print("18. 使前面各数顺序向后移m个位置")
    print("19. 找出最后留下的人的编号")
    print("20. 按奇偶分别求和")

    choice = input()
    if choice == "q":
        break
    elif choice == "1":
        year = int(input("请输入年份: "))
        month = int(input("请输入月份: "))
        day = int(input("请输入日期: "))
        print(math_functions.day_of_year(year, month, day))
    elif choice == "2":
        math_functions.multiplication_table()
    elif choice == "3":
        primes = math_functions.count_primes_under_1000()
        print(f"1000以内素数个数为: {len(primes)}")
        print("素数列表:", primes)
    elif choice == "4":
        n = int(input("请输入正整数: "))
        math_functions.prime_factorization(n)
    elif choice == "5":
        math_functions.grade_judgment()
    elif choice == "6":
        math_functions.digit_analysis()
    elif choice == "7":
        math_functions.count_characters()
    elif choice == "8":
        math_functions.sum_of_numbers()
    elif choice == "9":
        math_functions.find_perfect_numbers()
    elif choice == "10":
        math_functions.sum_of_fraction_sequence()
    elif choice == "11":
        math_functions.sum_of_factorials()
    elif choice == "12":
        math_functions.find_number()
    elif choice == "13":
        math_functions.print_diamond()
    elif choice == "14":
        math_functions.rabbit_count()
    elif choice == "15":
        math_functions.sort_numbers()
    elif choice == "16":
        math_functions.matrix_diagonal_sum()
    elif choice == "17":
        math_functions.insert_into_sorted_array()
    elif choice == "18":
        math_functions.shift_numbers()
    elif choice == "19":
        math_functions.last_remaining()
    elif choice == "20":
        n = int(input("请输入整数n: "))
        result = math_functions.sum_series(n)
        print(f"结果为: {result}")
    else:
        print("无效的选择，请重新输入！")
        